package com.turing.post.transaction.impl;

import java.util.Date;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import com.turing.post.transaction.util.MchChkAccDetail;
import com.turing.post.transaction.util.MchChkAccDetailDao;
import com.turing.post.util.GeneralDao;
import com.turing.post.util.PCPSApplicationException;

@Stateless(mappedName = "transaction.impl.MchChkAccDetailDaoImpl")
@Remote
@Local
public class MchChkAccDetailDaoImpl implements MchChkAccDetailDao {
	/**
	 * 实体管理器
	 * 
	 * @see javax.persistence.EntityManager
	 */
	@PersistenceContext
	protected EntityManager _em;

	@Override
	public void insert(MchChkAccDetail mcac) throws PCPSApplicationException {
		GeneralDao.insert(_em, mcac);
	}

	@Override
	public void delAllMchChkAccDetailDaoByCheckDate(String merchantNo,
			Date checkDate) {
		String sql = "delete from MchChkAccDetail where merchantNo = ?1 and checkDate = ?2";
		Query query = _em.createNativeQuery(sql);
		query.setParameter(1, merchantNo);
		query.setParameter(2, checkDate);
		query.executeUpdate();
	}
}